package com.cfpl.admin_vegetable_service.controller;

import com.cfpl.admin_vegetable_service.service.ChinasService;
import com.cfpl.project_common.pojo.Chinas;
import com.cfpl.project_common.result.BaseResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Auther: wrp
 * @Date: 2023/11/6 - 14:41
 * @Description: com.cfpl.admin_service.controller
 * @version: 1.0
 */
@CrossOrigin
@RestController
@RequestMapping("/chinas")
@Slf4j
@Api(tags = "省市区三级联动")
public class ChinasController {

    @Autowired
    private ChinasService chinasService;

    @GetMapping("/getRegions")
    public BaseResult<List<Chinas>> getRegions () {
        List<Chinas> json = chinasService.getRegions();

        if (json == null) {
            return new BaseResult(500,"查询失败",null);
        }
        return BaseResult.ok(json);

    }



}
